//
//  CancledDetailOrderController.m
//  EastMarket
//
//  Created by 李鹏程 on 16/12/21.
//  Copyright © 2016年 guoguo. All rights reserved.
//

#import "CancledDetailOrderController.h"

@interface CancledDetailOrderController ()
{
    UIView *viewPay;
    UIView *viewDelete;
}
@end

@implementation CancledDetailOrderController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title = @"订单详情";
    self.view.backgroundColor = EastMarket_backgroundColor;
    _dataSourceArr = [[NSMutableArray alloc] init];
    //    [self initHeaderViewUI];
    [self loadViewOrderDetail];
    [SVProgressHUD showWithStatus:@"加载中"];
    [SVProgressHUD setDefaultStyle:SVProgressHUDStyleCustom];
    [SVProgressHUD setForegroundColor:EastMarket_MainToneColor];
    [SVProgressHUD setDefaultMaskType:SVProgressHUDMaskTypeClear];
}
- (void)initHeaderViewUI {
    
    CGFloat spacing = 8.0f;
    CGFloat border = 1.0f;
    CGFloat viewHeight = 44.0f;
    
    UIScrollView *applicationSV = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
    applicationSV.showsVerticalScrollIndicator = YES;
    applicationSV.showsVerticalScrollIndicator = NO;
    applicationSV.backgroundColor = [UIColor clearColor];
    applicationSV.scrollEnabled = YES;
    [self.view addSubview:applicationSV];
    
    UIView *viewAddress = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, viewHeight * 2)];
    viewAddress.backgroundColor = EastMatket_AddressColor;
    
    CALayer *bottomBorder = [CALayer layer];
    float height = viewAddress.frame.size.height - 2.0f;
    float width=viewAddress.frame.size.width;
    bottomBorder.frame = CGRectMake(0.0f, height, width, 2.0f);
    bottomBorder.backgroundColor =  [UIColor colorWithPatternImage:[UIImage imageNamed:@"rainbow_line"]].CGColor;
    [viewAddress.layer addSublayer:bottomBorder];
    
    [applicationSV addSubview:viewAddress];
    
    UILabel *lblReceiverNameAndReceiverPhone = [[UILabel alloc] initWithFrame:CGRectMake(spacing * 2 + 22, spacing, viewAddress.frame.size.width - 2 * spacing, viewHeight - spacing)];
    lblReceiverNameAndReceiverPhone.text = [NSString stringWithFormat:@"%@   %@", [_orderDetailDic objectForKey:@"receiverName"], [_orderDetailDic objectForKey:@"receiverPhone"]];
    lblReceiverNameAndReceiverPhone.font = [UIFont systemFontOfSize:16];
    [viewAddress addSubview:lblReceiverNameAndReceiverPhone];
    
    UIImageView *markImg = [[UIImageView alloc] initWithFrame:CGRectMake(spacing, (viewHeight - 22 - lblReceiverNameAndReceiverPhone.frame.origin.y) / 2 + lblReceiverNameAndReceiverPhone.frame.origin.y + lblReceiverNameAndReceiverPhone.frame.size.height, 22, 22)];
    markImg.image = [UIImage imageNamed:@"地理位置"];
    [viewAddress addSubview:markImg];
    
    UILabel *lblReceiverAddress = [[UILabel alloc] initWithFrame:CGRectMake(markImg.frame.size.width + markImg.frame.origin.x + spacing, lblReceiverNameAndReceiverPhone.frame.origin.y + lblReceiverNameAndReceiverPhone.frame.size.height, viewAddress.frame.size.width - 2 * spacing - markImg.frame.origin.x - markImg.frame.size.width, viewHeight - spacing)];
    lblReceiverAddress.text = [NSString stringWithFormat:@"%@", [_orderDetailDic objectForKey:@"receiverAddress"]];
    lblReceiverAddress.font = [UIFont systemFontOfSize:16];
    lblReceiverAddress.numberOfLines = 0;
    [viewAddress addSubview:lblReceiverAddress];
    
    UIView *viewOrderNO = [[UIView alloc] initWithFrame:CGRectMake(0, viewAddress.frame.origin.y + viewAddress.frame.size.height + spacing * 2, SCREEN_WIDTH, viewHeight)];
    viewOrderNO.backgroundColor = [UIColor whiteColor];
    [applicationSV addSubview:viewOrderNO];
    [self addSubDetailViewsSpecial:viewOrderNO iconName:@"" iconLeft:0 title:@"订单号" titleLeft:8 hint:[NSString stringWithFormat:@"%@", [_orderDetailDic objectForKey:@"no"]]];
    
    UIView *viewOrderStatus = [[UIView alloc] initWithFrame:CGRectMake(0, viewOrderNO.frame.origin.y + viewOrderNO.frame.size.height + border, SCREEN_WIDTH, viewHeight)];
    viewOrderStatus.backgroundColor = [UIColor whiteColor];
    [applicationSV addSubview:viewOrderStatus];
    [self addSubDetailViewsSpecial:viewOrderStatus iconName:@"" iconLeft:0 title:@"状   态" titleLeft:8 hint:[NSString stringWithFormat:@"%@", [_orderDetailDic objectForKey:@"statusTitle"]]];
    
    UIView *viewSellerName = [[UIView alloc] initWithFrame:CGRectMake(0, viewOrderStatus.frame.origin.y + viewOrderStatus.frame.size.height + border, SCREEN_WIDTH, viewHeight)];
    viewSellerName.backgroundColor = [UIColor whiteColor];
    [applicationSV addSubview:viewSellerName];
    [self addSubDetailViewsSpecial:viewSellerName iconName:@"" iconLeft:0 title:@"供应商" titleLeft:8 hint:[NSString stringWithFormat:@"%@", [_orderDetailDic objectForKey:@"sellerName"]]];
    
    UIView *viewOrderFrom = [[UIView alloc] initWithFrame:CGRectMake(0, viewSellerName.frame.origin.y + viewSellerName.frame.size.height + border, SCREEN_WIDTH, viewHeight)];
    viewOrderFrom.backgroundColor = [UIColor whiteColor];
    [applicationSV addSubview:viewOrderFrom];
    [self addSubDetailViewsSpecial:viewOrderFrom iconName:@"" iconLeft:0 title:@"来   源" titleLeft:8 hint:[NSString stringWithFormat:@"%@", [_orderDetailDic objectForKey:@"fromTitle"]]];
    
    _tabView = [[UITableView alloc] initWithFrame:CGRectMake(8, viewOrderFrom.frame.origin.y + viewOrderFrom.frame.size.height + spacing * 2, SCREEN_WIDTH - 16, 80 * _dataSourceArr.count) style:UITableViewStylePlain];
    _tabView.showsVerticalScrollIndicator = false;
    _tabView.delegate = self;
    _tabView.dataSource = self;
    //    _tabView.separatorStyle = UITableViewCellSeparatorStyleNone;
    _tabView.backgroundColor = EastMarket_backgroundColor;
    [self setExtraCellLineHidden:_tabView];
    [applicationSV addSubview:_tabView];
    
    UIView *viewTheWayPay = [[UIView alloc] initWithFrame:CGRectMake(0, _tabView.frame.origin.y + _tabView.frame.size.height + spacing * 2, SCREEN_WIDTH, viewHeight)];
    viewTheWayPay.backgroundColor = [UIColor whiteColor];
    [applicationSV addSubview:viewTheWayPay];
    [self addSubDetailViewsSpecial:viewTheWayPay iconName:@"" iconLeft:0 title:@"付款方式" titleLeft:8 hint:[NSString stringWithFormat:@"%@", [_orderDetailDic objectForKey:@"payTypeTitle"]]];
    
    UIView *viewProductAmount = [[UIView alloc] initWithFrame:CGRectMake(0, viewTheWayPay.frame.origin.y + viewTheWayPay.frame.size.height, SCREEN_WIDTH, viewHeight)];
    viewProductAmount.backgroundColor = [UIColor whiteColor];
    [applicationSV addSubview:viewProductAmount];
    [self addSubDetailViewsSpecial:viewProductAmount iconName:@"" iconLeft:0 title:@"商品金额" titleLeft:8 hint:[NSString stringWithFormat:@"￥%.2lf", [[_orderDetailDic objectForKey:@"itemTotalFee"] floatValue]]];
    
    UIView *viewOffers = [[UIView alloc] initWithFrame:CGRectMake(0, viewProductAmount.frame.origin.y + viewProductAmount.frame.size.height, SCREEN_WIDTH, viewHeight)];
    viewOffers.backgroundColor = [UIColor whiteColor];
    [applicationSV addSubview:viewOffers];
    [self addSubDetailViewsSpecial:viewOffers iconName:@"" iconLeft:0 title:@"优惠" titleLeft:8 hint:[NSString stringWithFormat:@"-￥%.2lf", [[_orderDetailDic objectForKey:@"discountFee"] floatValue]]];
    
    UIView *viewFreight = [[UIView alloc] initWithFrame:CGRectMake(0, viewOffers.frame.origin.y + viewOffers.frame.size.height, SCREEN_WIDTH, viewHeight)];
    viewFreight.backgroundColor = [UIColor whiteColor];
    [applicationSV addSubview:viewFreight];
    [self addSubDetailViewsSpecial:viewFreight iconName:@"" iconLeft:0 title:@"运费" titleLeft:8 hint:[NSString stringWithFormat:@"￥%.2lf", [[_orderDetailDic objectForKey:@"deliveryFee"] floatValue]]];
    
    UIView *viewOrderAmount = [[UIView alloc] initWithFrame:CGRectMake(0, viewFreight.frame.origin.y + viewFreight.frame.size.height, SCREEN_WIDTH, viewHeight)];
    viewOrderAmount.backgroundColor = [UIColor whiteColor];
    [applicationSV addSubview:viewOrderAmount];
    [self addSubDetailViewsSpecial:viewOrderAmount iconName:@"" iconLeft:0 title:@"订单金额" titleLeft:8 hint:[NSString stringWithFormat:@"￥%.2lf", [[_orderDetailDic objectForKey:@"totalFee"] floatValue]]];
    
    UIView *viewPaiedAmount = [[UIView alloc] initWithFrame:CGRectMake(0, viewOrderAmount.frame.origin.y + viewOrderAmount.frame.size.height + 2 * spacing, SCREEN_WIDTH, viewHeight)];
    viewPaiedAmount.backgroundColor = [UIColor whiteColor];
    [applicationSV addSubview:viewPaiedAmount];
    [self addSubDetailViewsSpecial:viewPaiedAmount iconName:@"" iconLeft:0 title:@"已付金额" titleLeft:8 hint:[NSString stringWithFormat:@"￥%.2lf", [[_orderDetailDic objectForKey:@"paidFee"] floatValue]]];
    
    UIView *viewBackAmount = [[UIView alloc] initWithFrame:CGRectMake(0, viewPaiedAmount.frame.origin.y + viewPaiedAmount.frame.size.height, SCREEN_WIDTH, viewHeight)];
    viewBackAmount.backgroundColor = [UIColor whiteColor];
    [applicationSV addSubview:viewBackAmount];
    [self addSubDetailViewsSpecial:viewBackAmount iconName:@"" iconLeft:0 title:@"退款金额" titleLeft:8 hint:[NSString stringWithFormat:@"￥%.2lf", [[_orderDetailDic objectForKey:@"refundFee"] floatValue]]];
    
    UIView *viewCreateTime = [[UIView alloc] initWithFrame:CGRectMake(0, viewBackAmount.frame.origin.y + viewBackAmount.frame.size.height + 2 * spacing, SCREEN_WIDTH, viewHeight)];
    viewCreateTime.backgroundColor = [UIColor whiteColor];
    [applicationSV addSubview:viewCreateTime];
    [self addSubDetailViewsSpecial:viewCreateTime iconName:@"" iconLeft:0 title:@"下单时间" titleLeft:8 hint:[NSString stringWithFormat:@"%@", [GlobalUnit getDateFormatterByMillisecond:[NSString stringWithFormat:@"%@", [_orderDetailDic objectForKey:@"createTime"]]]]];
    //bottomView
    viewDelete = [[UIView alloc] initWithFrame:CGRectMake(0, viewCreateTime.frame.origin.y + viewCreateTime.frame.size.height + spacing * 4, SCREEN_WIDTH, 44)];
    viewDelete.backgroundColor = [UIColor clearColor];
    [applicationSV addSubview:viewDelete];
    
    UIButton *btnDelete = [UIButton buttonWithType:UIButtonTypeSystem];
    btnDelete.frame = CGRectMake(spacing, 0, viewDelete.frame.size.width - 2 * spacing, viewDelete.frame.size.height);
    [btnDelete setTitle:@"删除订单" forState:UIControlStateNormal];
    [btnDelete setBackgroundColor:EastMarket_BlueColor];
    [btnDelete setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [btnDelete addTarget:self action:@selector(btnDeleteClicked:) forControlEvents:UIControlEventTouchUpInside];
    btnDelete.layer.cornerRadius = 5.0f;
    [viewDelete addSubview:btnDelete];
    
    //status  订单状态 可选值：WAIT_PAY  WAIT_VERIFY  VERIFIED  WAIT_CANCEL,CANCELED
    
    applicationSV.contentSize = CGSizeMake(SCREEN_WIDTH, viewDelete.frame.origin.y + viewDelete.frame.size.height + TabBarHeight + TopBarHeight);
}

- (void)initOrderListUI {
    
    //    CGFloat spacing = 8.0f;
    
}

// 订单列表请求
- (void)loadViewOrderDetail {
    
    [NSThread detachNewThreadSelector:@selector(callServerGetOrderDetail) toTarget:self  withObject:Nil];
}

- (void)callServerGetOrderDetail {
    
    NSDictionary *orderDetailDic = [AppServiceInterface orderDetail:_strId];
    [self performSelectorOnMainThread:@selector(updateOrderDetail:) withObject:orderDetailDic waitUntilDone:NO];
}

- (void)updateOrderDetail:(NSDictionary *)dic {
    
    [SVProgressHUD dismiss];
    if (dic && [[dic objectForKey:@"success"] integerValue] == 1) {
        if (![[dic objectForKey:@"data"] isKindOfClass:[NSNull class]]) {
            _orderDetailDic = [dic objectForKey:@"data"];
            _strOrderStatus =  [NSString stringWithFormat:@"%@", [_orderDetailDic objectForKey:@"statusTitle"]];
            [_dataSourceArr addObjectsFromArray:[_orderDetailDic objectForKey:@"orderItemList"]];
            [self initHeaderViewUI];
            [_tabView reloadData];
        }
    }
}

- (void)reloadDataAfterCanleOrder {
    
    [NSThread detachNewThreadSelector:@selector(callServerGetOrderDetailAfterCancle) toTarget:self  withObject:Nil];
}

- (void)callServerGetOrderDetailAfterCancle {
    
    NSDictionary *orderDetailDic = [AppServiceInterface orderDetail:_strId];
    [self performSelectorOnMainThread:@selector(updateOrderDetailAfterCanle:) withObject:orderDetailDic waitUntilDone:NO];
}

- (void)updateOrderDetailAfterCanle:(NSDictionary *)dic {
    
    if (dic && [[dic objectForKey:@"success"] integerValue] == 1) {
        if (![[dic objectForKey:@"data"] isKindOfClass:[NSNull class]]) {
            [_dataSourceArr removeAllObjects];
            _orderDetailDic = [dic objectForKey:@"data"];
            [_dataSourceArr addObjectsFromArray:[_orderDetailDic objectForKey:@"orderItemList"]];
            //            [self initHeaderViewUI];
            [_tabView reloadData];
        }
    }
}

// 订单
- (void)callServerOrderDelete:(NSString *)itemId {
    
    NSDictionary *resultOfOrderDelete = [AppServiceInterface orderDelete:itemId];
    [self performSelectorOnMainThread:@selector(updateUIAfterOrderDelete:) withObject:resultOfOrderDelete waitUntilDone:NO];
}

- (void)updateUIAfterOrderDelete:(NSDictionary *)dic {
    
    [SVProgressHUD dismiss];
    if (dic && [[dic objectForKey:@"success"] integerValue] == 1) {
        NSString *showMsg = @"删除订单成功";
        if ([[dic objectForKey:@"msg"] isKindOfClass:[NSNull class]]) {
            showMsg = [NSString stringWithFormat:@"%@", [dic objectForKey:@"msg"]];
        }
        [GlobalUnit showMessage:[NSString stringWithFormat:@"%@", showMsg]];
        NSNotification *notice = [NSNotification notificationWithName:NotificationReloadData object:nil];
        [[NSNotificationCenter defaultCenter] postNotification:notice];
        [self.navigationController popViewControllerAnimated:true];
        
    } else if (dic && [[dic objectForKey:@"success"] integerValue] == 0) {
        
        [GlobalUnit showMessage:[NSString stringWithFormat:@"%@", [dic objectForKey:@"msg"]]];
    } else {
        
        [GlobalUnit showAlertHint:@"温馨提示！" message:@"请求服务器失败，请稍后重试"];
    }
}

//多余的空行上不显示分割线
- (void)setExtraCellLineHidden: (UITableView *)tableView{
    UIView *view =[ [UIView alloc]init];
    view.backgroundColor = [UIColor clearColor];
    [tableView setTableFooterView:view];
    [tableView setTableHeaderView:view];
}
//各条件view块添加详细内容
-(UILabel *)addSubDetailViews:(UIView *)parentView iconName:(NSString *)imageName iconLeft:(CGFloat)iconX title:(NSString*)titleName titleLeft:(CGFloat)titleX hint:(NSString*)hintText{
    //开头图标
    UIImageView *viewIcon = [[UIImageView alloc] initWithFrame:CGRectMake(iconX, 0, 20, 20)];
    [parentView addSubview:viewIcon];
    viewIcon.center = CGPointMake(viewIcon.center.x, parentView.frame.size.height/2);
    [viewIcon setImage:[UIImage imageNamed:imageName]];
    
    //标题
    UILabel *lblTitle = [[UILabel alloc] initWithFrame:CGRectMake(titleX, 0, 54 + 10, 32)];
    [parentView addSubview:lblTitle];
    lblTitle.center = CGPointMake(lblTitle.center.x, parentView.frame.size.height/2);
    lblTitle.numberOfLines = 1;
    lblTitle.text = titleName;
    lblTitle.lineBreakMode = NSLineBreakByWordWrapping;
    //lblTitle.textColor = [UIColor colorWithRed:167.0/255 green:167.0/255 blue:167.0/255 alpha:1];
    [lblTitle setTextColor:[UIColor blackColor]];
    lblTitle.backgroundColor =[UIColor clearColor];
    lblTitle.font = [UIFont fontWithName:@"Arial" size:16];
    
    //右箭头  15*15，距离右边也是15
    UIImageView *viewArrow = [[UIImageView alloc] initWithFrame:CGRectMake(parentView.frame.size.width-15-15, 0, 15, 15)];
    
    viewArrow.center = CGPointMake(viewArrow.center.x, parentView.frame.size.height/2);
    [viewArrow setImage:[UIImage imageNamed:@"rightArrow"]];
    
    //内容，初始化时为提示文字
    CGFloat left = 70;
    if ([GlobalUnit isBlankString:hintText]) {
        [parentView addSubview:viewArrow];
    }
    //    else {
    //
    //        left = SCREEN_WIDTH - 64 - 24;
    //    }
    
    UILabel *lblContent = [[UILabel alloc] initWithFrame:CGRectMake(left, 0, viewArrow.frame.origin.x - left - 15 + 15 + 16, 22 + 8)];
    [parentView addSubview:lblContent];
    lblContent.center = CGPointMake(lblContent.center.x, parentView.frame.size.height/2);
    lblContent.text = hintText;
    lblContent.textColor = EastMarket_darkGreyFontColor;
    lblContent.backgroundColor =[UIColor clearColor];
    lblContent.textAlignment = NSTextAlignmentRight;
    lblContent.font = [UIFont fontWithName:@"Arial" size:16];
    
    return lblContent;
}

//各条件view块添加详细内容
-(UILabel *)addSubDetailViewsSpecial:(UIView *)parentView iconName:(NSString *)imageName iconLeft:(CGFloat)iconX title:(NSString*)titleName titleLeft:(CGFloat)titleX hint:(NSString*)hintText{
    //开头图标
    UIImageView *viewIcon = [[UIImageView alloc] initWithFrame:CGRectMake(iconX, 0, 20, 20)];
    [parentView addSubview:viewIcon];
    viewIcon.center = CGPointMake(viewIcon.center.x, parentView.frame.size.height/2);
    [viewIcon setImage:[UIImage imageNamed:imageName]];
    
    //标题
    UILabel *lblTitle = [[UILabel alloc] initWithFrame:CGRectMake(titleX, 0, 54 + 10, 32)];
    [parentView addSubview:lblTitle];
    lblTitle.center = CGPointMake(lblTitle.center.x, parentView.frame.size.height/2);
    lblTitle.numberOfLines = 1;
    lblTitle.text = titleName;
    lblTitle.lineBreakMode = NSLineBreakByWordWrapping;
    //lblTitle.textColor = [UIColor colorWithRed:167.0/255 green:167.0/255 blue:167.0/255 alpha:1];
    [lblTitle setTextColor:EastMarket_darkGreyFontColor];
    lblTitle.backgroundColor =[UIColor clearColor];
    lblTitle.font = [UIFont fontWithName:@"Arial" size:16];
    
    //右箭头  15*15，距离右边也是15
    UIImageView *viewArrow = [[UIImageView alloc] initWithFrame:CGRectMake(parentView.frame.size.width-15-15, 0, 15, 15)];
    
    viewArrow.center = CGPointMake(viewArrow.center.x, parentView.frame.size.height/2);
    [viewArrow setImage:[UIImage imageNamed:@"rightArrow"]];
    
    //内容，初始化时为提示文字
    CGFloat left = 70;
    if ([GlobalUnit isBlankString:hintText]) {
        [parentView addSubview:viewArrow];
    }
    //    else {
    //
    //        left = SCREEN_WIDTH - 64 - 24;
    //    }
    
    UILabel *lblContent = [[UILabel alloc] initWithFrame:CGRectMake(left, 0, viewArrow.frame.origin.x - left - 15 + 15 + 16, 22 + 8)];
    [parentView addSubview:lblContent];
    lblContent.center = CGPointMake(lblContent.center.x, parentView.frame.size.height/2);
    lblContent.text = hintText;
    lblContent.textColor = EastMarket_darkBlackFontColor;
    lblContent.backgroundColor =[UIColor clearColor];
    lblContent.textAlignment = NSTextAlignmentRight;
    lblContent.font = [UIFont fontWithName:@"Arial" size:16];
    
    return lblContent;
}


//各条件view块添加详细内容
-(UILabel *)addSubDetailViews:(UIView *)parentView iconName:(NSString *)imageName title:(NSString*)titleName hint:(NSString*)hintText{
    
    return [self addSubDetailViews:parentView iconName:imageName iconLeft:8 title:titleName titleLeft:16 hint:hintText];
    
}
#pragma mark -- UITableViewDelegate &  UITableViewDatasource

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    return 80;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    return _dataSourceArr.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    static NSString *cellIdentifier = @"cell";
    OrderDetailViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
    if (cell == nil) {
        cell = [[OrderDetailViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.backgroundColor = [UIColor whiteColor];
    NSInteger curRow = [indexPath row];
    NSDictionary *orderDetailDic = [_dataSourceArr objectAtIndex:curRow];
    
    cell.imgProductIcon.image = [UIImage imageNamed:@"NoProductImage"];
    cell.lblProductName.text = [NSString stringWithFormat:@"%@", [[orderDetailDic objectForKey:@"item"] objectForKey:@"title"]];
    cell.lblProductPrice.text = [NSString stringWithFormat:@"%.2lf元", [[orderDetailDic objectForKey:@"price"] floatValue]];
    cell.lblProductNum.text = [NSString stringWithFormat:@"X %ld", [[orderDetailDic objectForKey:@"num"] integerValue]];
    
    return cell;
}

- (void)btnPayClicked:(UIButton *)btn {
    
    debugMethod();
    CheckoutCounterViewController *checkoutVC =[[CheckoutCounterViewController alloc] init];
    checkoutVC.strItemId = _strId;
    [self.navigationController pushViewController:checkoutVC animated:true];
}

- (void)btnDeleteClicked:(UIButton *)btn {
    
    UIAlertController *alerController = [UIAlertController alertControllerWithTitle:@"确认删除订单吗？" message:@"" preferredStyle:UIAlertControllerStyleAlert];
    UIAlertAction *cancleAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
    }];
    
    UIAlertAction *defaultAction = [UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        [NSThread detachNewThreadSelector:@selector(callServerOrderDelete:) toTarget:self  withObject:_strId];
        [SVProgressHUD showWithStatus:@"正在删除中"];
        [SVProgressHUD setDefaultStyle:SVProgressHUDStyleCustom];
        [SVProgressHUD setForegroundColor:EastMarket_MainToneColor];
        [SVProgressHUD setDefaultMaskType:SVProgressHUDMaskTypeClear];
    }];
    
    [alerController addAction:cancleAction];
    [alerController addAction:defaultAction];
    [self  presentViewController:alerController animated:YES completion:nil];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
